package com.yhp.bean;

import com.yhp.util.PageUtil;
import com.yhp.util.PeopleUtil;

import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

// 类名=表名   列名=属性名
public class Users implements HttpSessionBindingListener {

    //建立和Role之间的关系
    //一个用户对应一个角色
    private Role role;

    private Integer userId;
    private String userName;
    private Integer age;
    private String sex;
    private String passWord;
    private Integer status;


    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public Users() {
    }

    public Users(Integer userId, String userName, Integer age, String sex, String passWord, Integer status) {
        this.userId = userId;
        this.userName = userName;
        this.age = age;
        this.sex = sex;
        this.passWord = passWord;
        this.status = status;
    }

    @Override
    public String toString() {
        return "Users{" +
                "userId=" + userId +
                ", userName='" + userName + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", passWord='" + passWord + '\'' +
                ", status=" + status +
                '}';
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }


    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    @Override
    public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent) {
        System.out.println("---绑定---");
        PeopleUtil.PEOPLE_ON_LINE++;
    }

    @Override
    public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent) {
        System.out.println("---解绑---");
        PeopleUtil.PEOPLE_ON_LINE--;
    }




}
